home *** CD-ROM | disk | FTP | other *** search
/ Champak Vol A-4 / (Vol A-4) Vol. A4.iso / Games / tom_jerry_bowling.swf / scripts / frame_12 / DoAction.as
Text File  |  2008-03-04  |  10KB  |  399 lines

  1. function resetGame()
  2. {
  3.    i = 1;
  4.    while(i <= 10)
  5.    {
  6.       gameMC["frame-" + i] = "-";
  7.       i++;
  8.    }
  9.    frameNum = 1;
  10.    rollNum = 1;
  11.    pinsUp = [1,2,3,4,5,6,7,8,9,10];
  12.    pinsDown = new Array();
  13.    score = 0;
  14.    currentRoll = 0;
  15.    power = "";
  16.    pan = 0;
  17.    pinSplit = false;
  18.    showFrameNum();
  19. }
  20. function pinCheck()
  21. {
  22.    trace(pinsUp + " are the pins still standing.");
  23.    trace(pinsDown + " are the pins knocked down.");
  24.    trace("--------------------------------------------");
  25. }
  26. function mouseDownFunction()
  27. {
  28.    if(gameMC.gameState == "pickPan")
  29.    {
  30.       gameMC.laneLights.gotoAndPlay("L" + gameMC.pan);
  31.       gameMC.gameState = "pickPower";
  32.       gameMC.powerMeter.gotoAndPlay("loopHere");
  33.    }
  34. }
  35. function mouseUpFunction()
  36. {
  37.    if(gameMC.gameState == "pickPower")
  38.    {
  39.       gameMC.randomOneToThree = Math.floor(Math.random() * 3) + 1;
  40.       gameMC.powerMeter.stop();
  41.       gameMC.gameState = "bowl";
  42.       gameMC.jackie.gotoAndPlay("throw-" + gameMC.power);
  43.    }
  44. }
  45. function showFrameNum()
  46. {
  47.    gameMC.alerts.num.gotoAndStop(frameNum);
  48.    gameMC.alerts.gotoAndPlay("gameFrame");
  49. }
  50. function tapPin(pinNum)
  51. {
  52.    var _loc1_ = pinNum;
  53.    numOfPinsUp = pinsUp.length;
  54.    i = 0;
  55.    while(i < numOfPinsUp)
  56.    {
  57.       if(_loc1_ == pinsUp[i])
  58.       {
  59.          gameMC["pin-" + _loc1_].gotoAndPlay("wobble");
  60.          break;
  61.       }
  62.       i++;
  63.    }
  64. }
  65. function testPin(pinNum)
  66. {
  67.    var _loc1_ = pinNum;
  68.    numOfPinsUp = pinsUp.length;
  69.    i = 0;
  70.    while(i < numOfPinsUp)
  71.    {
  72.       if(_loc1_ == pinsUp[i])
  73.       {
  74.          gameMC.pinsUp.splice(i,1);
  75.          gameMC.pinsDown.push(_loc1_);
  76.          gameMC["pin-" + _loc1_].gotoAndPlay("hit");
  77.          gameMC.currentRoll = gameMC.currentRoll + 1;
  78.          break;
  79.       }
  80.       i++;
  81.    }
  82. }
  83. function pickUpTheSplit(side)
  84. {
  85.    gameMC.pinsUp = [];
  86.    gameMC.pinsDown.push(4,7,6,10);
  87.    gameMC.currentRoll = 4;
  88.    if(side == "left")
  89.    {
  90.       gameMC["pin-4"].gotoAndPlay("hitLeft");
  91.       gameMC["pin-6"].gotoAndPlay("hitLeft");
  92.       gameMC["pin-7"].gotoAndPlay("hit");
  93.       gameMC["pin-10"].gotoAndPlay("hit");
  94.    }
  95.    else if(side == "right")
  96.    {
  97.       gameMC["pin-4"].gotoAndPlay("hitRight");
  98.       gameMC["pin-6"].gotoAndPlay("hitRight");
  99.       gameMC["pin-7"].gotoAndPlay("hit");
  100.       gameMC["pin-10"].gotoAndPlay("hit");
  101.    }
  102. }
  103. function updatePinLights()
  104. {
  105.    numOfPinsDown = pinsDown.length;
  106.    i = 0;
  107.    while(i <= numOfPinsDown)
  108.    {
  109.       thisPin = pinsDown[i];
  110.       gameMC.pinLights["pinLight-" + thisPin].gotoAndPlay("unlit");
  111.       i++;
  112.    }
  113. }
  114. function playHitSound()
  115. {
  116.    i = 1;
  117.    while(i <= 3)
  118.    {
  119.       gameMC["sound_" + i].stop();
  120.       i++;
  121.    }
  122.    if(gameMC.currentRoll == 0)
  123.    {
  124.       sound_7.start(0,0);
  125.    }
  126.    else if(gameMC.currentRoll < 4)
  127.    {
  128.       sound_4.start(0,0);
  129.    }
  130.    else if(gameMC.currentRoll <= 7)
  131.    {
  132.       sound_5.start(0,0);
  133.    }
  134.    else if(gameMC.currentRoll > 7)
  135.    {
  136.       sound_6.start(0,0);
  137.    }
  138. }
  139. function resetBall()
  140. {
  141.    ball.gotoAndPlay(1);
  142.    laneLights.gotoAndPlay("L" + pan + "_fade");
  143.    markIt();
  144. }
  145. function markIt()
  146. {
  147.    if(rollNum == 1)
  148.    {
  149.       if(gameMC["frame_" + (frameNum - 1) + "-2"]._currentframe == 12)
  150.       {
  151.          score += 10 + currentRoll;
  152.          gameMC["frame-" + (frameNum - 1)] = score;
  153.       }
  154.       if(gameMC["frame_" + (frameNum - 1) + "-2"]._currentframe == 13)
  155.       {
  156.          if(gameMC["frame_" + (frameNum - 2) + "-2"]._currentframe == 13)
  157.          {
  158.             score += 20 + currentRoll;
  159.             gameMC["frame-" + (frameNum - 2)] = score;
  160.             if(currentRoll == 10)
  161.             {
  162.                gameMC.moreAlerts.gotoAndPlay("turkey");
  163.             }
  164.          }
  165.       }
  166.       if(currentRoll == 10)
  167.       {
  168.          gameMC.jackie.gotoAndPlay("strike");
  169.          if(frameNum == 10)
  170.          {
  171.             gameMC["frame_" + frameNum + "-1"].gotoAndStop("strike");
  172.          }
  173.          else
  174.          {
  175.             gameMC["frame_" + frameNum + "-2"].gotoAndStop("strike");
  176.          }
  177.          gameMC.alerts.gotoAndPlay("strike");
  178.       }
  179.       else
  180.       {
  181.          if(currentRoll == 0)
  182.          {
  183.             gameMC.jackie.gotoAndPlay("lose");
  184.             gameMC.alerts.gotoAndPlay("gutterball");
  185.          }
  186.          else
  187.          {
  188.             gameMC.jackie.gotoAndPlay("stall");
  189.             gameMC.alerts.count.gotoAndStop(gameMC.pinsDown.length);
  190.             gameMC.alerts.gotoAndPlay("count");
  191.          }
  192.          gameMC["frame_" + frameNum + "-1"].gotoAndStop(currentRoll + 2);
  193.          rollNum = 2;
  194.       }
  195.    }
  196.    else if(rollNum == 2)
  197.    {
  198.       if(gameMC["frame_" + (frameNum - 1) + "-2"]._currentframe == 13)
  199.       {
  200.          if(gameMC["frame_" + frameNum + "-1"]._currentframe == 13)
  201.          {
  202.             score += 20 + pinsDown.length;
  203.          }
  204.          else
  205.          {
  206.             score += 10 + pinsDown.length;
  207.          }
  208.          gameMC["frame-" + (frameNum - 1)] = score;
  209.       }
  210.       if(frameNum == 10)
  211.       {
  212.          if(gameMC["frame_10-1"]._currentframe == 13)
  213.          {
  214.             score += 10;
  215.             if(pinsUp.length == 0)
  216.             {
  217.                score += 10;
  218.                gameMC["frame_10-2"].gotoAndStop("strike");
  219.                gameMC.jackie.gotoAndPlay("strike");
  220.                gameMC.alerts.gotoAndPlay("strike");
  221.             }
  222.             else
  223.             {
  224.                gameMC["frame_10-2"].gotoAndStop(currentRoll + 2);
  225.                rollNum = 3;
  226.                gameMC.alerts.count.gotoAndStop(gameMC.pinsDown.length);
  227.                gameMC.alerts.gotoAndPlay("count");
  228.             }
  229.          }
  230.          else if(pinsUp.length == 0)
  231.          {
  232.             gameMC["frame_10-2"].gotoAndStop("spare");
  233.             gameMC.jackie.gotoAndPlay("spare");
  234.             gameMC.alerts.gotoAndPlay("spare");
  235.             score += 10;
  236.          }
  237.          else
  238.          {
  239.             gameMC["frame_10-2"].gotoAndStop(currentRoll + 2);
  240.             score += pinsDown.length;
  241.             markFinalScore();
  242.          }
  243.       }
  244.       else if(pinsUp.length == 0)
  245.       {
  246.          gameMC.jackie.gotoAndPlay("fist");
  247.          gameMC["frame_" + frameNum + "-2"].gotoAndStop("spare");
  248.       }
  249.       else
  250.       {
  251.          gameMC["frame_" + frameNum + "-2"].gotoAndStop(currentRoll + 2);
  252.          score += gameMC.pinsDown.length;
  253.          gameMC["frame-" + frameNum] = score;
  254.          gameMC.jackie.gotoAndPlay("stall");
  255.          gameMC.alerts.gotoAndPlay("wait");
  256.       }
  257.    }
  258.    else if(rollNum == 3)
  259.    {
  260.       if(pinsUp.length == 0)
  261.       {
  262.          score += 10;
  263.          if(gameMC["frame_10-2"]._currentframe > 11)
  264.          {
  265.             gameMC["frame_10-3"].gotoAndStop("strike");
  266.          }
  267.          else
  268.          {
  269.             gameMC["frame_10-3"].gotoAndStop("spare");
  270.          }
  271.       }
  272.       else
  273.       {
  274.          gameMC["frame_10-3"].gotoAndStop(currentRoll + 2);
  275.          score += gameMC.pinsDown.length;
  276.       }
  277.       markFinalScore();
  278.    }
  279.    updatePinLights();
  280. }
  281. function markFinalScore()
  282. {
  283.    gameMC.jackie.gotoAndPlay("stall");
  284.    gameMC.logo.gotoAndStop("smiling");
  285.    gameMC["frame-10"] = score;
  286.    gameMC.finalScore = score;
  287.    gameMC.alerts.gotoAndPlay("finalScore");
  288. }
  289. function newFrame()
  290. {
  291.    resetPins();
  292.    if(gameMC.frameNum < 10)
  293.    {
  294.       rollNum = 1;
  295.       frameNum++;
  296.       gameMC.frameBoxes.gotoAndStop(frameNum);
  297.    }
  298.    else if(gameMC.rollNum == 1)
  299.    {
  300.       gameMC.rollNum = 2;
  301.    }
  302.    else if(gameMC.rollNum == 2)
  303.    {
  304.       gameMC.rollNum = 3;
  305.    }
  306.    pinSplit = false;
  307.    i = 1;
  308.    while(i <= 10)
  309.    {
  310.       gameMC.pinLights["pinLight-" + i].gotoAndPlay("lit");
  311.       i++;
  312.    }
  313. }
  314. function pickPan()
  315. {
  316.    currentRoll = 0;
  317.    gameState = "pickPan";
  318.    powerMeter.play();
  319.    jackie.gotoAndPlay("idle");
  320.    laneLights.gotoAndPlay("blink");
  321. }
  322. function resetPins()
  323. {
  324.    pinsUp = [1,2,3,4,5,6,7,8,9,10];
  325.    pinsDown = [];
  326.    gameMC.ctrlclip.gotoAndPlay("setPins");
  327. }
  328. function getScore()
  329. {
  330.    return score;
  331. }
  332. function openHelpWin()
  333. {
  334.    trace("displaying help");
  335.    gameMC.helpWin_mc.open();
  336. }
  337. function closeHelpWin()
  338. {
  339.    if(helpWindow._currentframe > 1)
  340.    {
  341.       helpWindow.play();
  342.    }
  343. }
  344. function pause()
  345. {
  346.    helpButton.helpButton.enabled = false;
  347.    set("variables:pause",true);
  348. }
  349. function unPause()
  350. {
  351.    helpButton.helpButton.enabled = true;
  352.    set("variables:pause",false);
  353. }
  354. function getAdInfo()
  355. {
  356.    var _loc1_ = {id:1,path:"ad1.jpg",link:"http://www.kidswb.com",text:"howdy"};
  357.    return _loc1_;
  358. }
  359. function adClick()
  360. {
  361.    getURL(gameMC.adInfo.link,"");
  362. }
  363. function displayAd(ad)
  364. {
  365.    gameMC.adInfo = ad;
  366.    gameMC.ad_100x100.loadMovie(ad.path);
  367. }
  368. function restart()
  369. {
  370.    containerMC.resetContainer();
  371.    containerMC.init();
  372.    score = 0;
  373.    which_level = 1;
  374. }
  375. resetGame();
  376. gameMC.createEmptyMovieClip("soundLib",1);
  377. i = 1;
  378. while(i <= 9)
  379. {
  380.    soundLib.createEmptyMovieClip("holder_" + i,i);
  381.    gameMC["sound_" + i] = new Sound(soundLib["holder_" + i]);
  382.    i++;
  383. }
  384. sound_1.attachSound("lightRoll");
  385. sound_2.attachSound("mediumRoll");
  386. sound_3.attachSound("hardRoll");
  387. sound_4.attachSound("lightHit");
  388. sound_5.attachSound("mediumHit");
  389. sound_6.attachSound("hardHit");
  390. sound_7.attachSound("gutter");
  391. sound_8.attachSound("loop");
  392. sound_9.attachSound("wood");
  393. if(initGame == null)
  394. {
  395.    initGame = true;
  396.    containerMC.init();
  397.    displayAd(containerMC.getAdInfo());
  398. }
  399.